<?php
/**
 * Created by PhpStorm.
 * User: w-pc
 * Date: 2017/03/07
 * Time: 17:10
 */

namespace Admin\Controller;
use Think\Controller;
class MessageController extends CommonController {
    public function index(){
        $m_state = request('get','int','m_state');
        $page = request('get','int','page',1);
        $message_list = D('Message')->get_MessageList($m_state);
        $page_list = pageKeyList($page,'message','m_state',$m_state,$message_list);
        $message_list = pageList($page,$message_list);
        $this->assign('page_list',$page_list);
        $this->assign('message_list',$message_list);
        $this->display();
    }
    public function show(){
        $m_id = request('get','int','m_id');
        $message = D('Message')->get_Message($m_id);
        $this->assign('message',$message);
        $this->display();
    }
    public function upload(){
        $arr['m_name'] = request('post','str','m_name');
        $arr['m_email'] = request('post','str','m_email');
        $arr['m_time'] = request('post','str','m_time');
        $arr['m_content'] = request('post','str','m_content');
        $m_id = request('post','int','m_id');
        D('Message')->set_Message($m_id,$arr);
        $this->redirect('/admin.php?c=message&a=show&m_id='.$m_id);
    }
    public function stick(){
        $m_id = request('get','int','m_id');
        D('Message')->set_Stick($m_id);
        $last_url = $_SERVER['HTTP_REFERER'];
        $this->redirect($last_url);
    }
    public function delete(){
        $m_id = request('post','int','m_id');
        D('Message')->set_Delete($m_id);
    }
}